package com.ruoyi.syf.handler.deleteChain;

import com.ruoyi.syf.handler.deleteChain.chainHandler.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 删除业务数据责任链
 */
@Service
public class DeleteService {

    private final ObjectHandler objectHandler;
    private final UnitHandler unitHandler;
    private final EvaluationHandler evaluationHandler;
    private final DetailHandler detailHandler;
    private final MeasureHandle measureHandle;
    private final TaskHandler taskHandler;

    @Autowired
    public DeleteService(ObjectHandler objectHandler,
                         UnitHandler unitHandler,
                         EvaluationHandler evaluationHandler,
                         DetailHandler detailHandler,
                         MeasureHandle measureHandle,
                         TaskHandler taskHandler){
        this.objectHandler = objectHandler;
        this.unitHandler = unitHandler;
        this.evaluationHandler = evaluationHandler;
        this.detailHandler = detailHandler;
        this.measureHandle = measureHandle;
        this.taskHandler = taskHandler;
        /*
          设置责任链顺序：安全风险对象->安全风险单元->风险判定->风险判定详情->管控措施->排查任务
         */
        objectHandler.setNext(unitHandler);
        unitHandler.setNext(evaluationHandler);
        evaluationHandler.setNext(detailHandler);
        detailHandler.setNext(measureHandle);
        measureHandle.setNext(taskHandler);
    }

    /**
     * 安全风险对象->安全风险单元->风险判定->风险判定详情->管控措施->排查任务
     */
    public void deleteObject(List<Long> ids) {
        objectHandler.handleDelete(ids);
    }

    /**
     * 安全风险单元->风险判定->风险判定详情->管控措施->排查任务
     */
    public void deleteUnit(List<Long> ids) {
        unitHandler.handleDelete(ids);
    }

    /**
     * 风险判定->风险判定详情->管控措施->排查任务
     */
    public void deleteEvaluation(List<Long> ids) {
        evaluationHandler.handleDelete(ids);
    }

    /**
     * 风险判定详情->管控措施->排查任务
     */
    public void deleteDetail(List<Long> ids) {
        detailHandler.handleDelete(ids);
    }

    /**
     * 管控措施->排查任务
     */
    public void deleteMeasure(List<Long> ids) {
        measureHandle.handleDelete(ids);
    }

}
